
import app
import requests
#创建部门管理模块的类
class  DepApi:

    def __init__(self):
        self.url_dep_all=app.BASE_HOSE+"/api/company/department"
        self.url_dep_sample=app.BASE_HOSE+"/api/company/department/{}"

    #封装添加部门接口
    def add_dep(self,token,json_dict):
        header_dict ={"Authorization":token}
        return requests.post(url=self.url_dep_all,headers= header_dict,json=json_dict)

    #封装查询部门接口
    def query_dep(self,token,dep_id):
        header_dict ={"Authorization":token}
        return requests.get(url=self.url_dep_sample.format(dep_id),headers=header_dict)

    #封装修改部门接口
    def update_dep(self,token,json_data,dep_id):
        header_dict ={"Authorization":token}
        return requests.put(url=self.url_dep_sample.format(dep_id),headers=header_dict,json=json_data)

    #封装删除部门接口
    def del_dep(self,token,dep_id):
        header_dict={"Authorization":token}
        return requests.delete(url=self.url_dep_sample.format(dep_id),headers=header_dict)


